package cn.dhnep.demo.service.impl;


import cn.dhnep.demo.mapper.ActivityMapper;
import cn.dhnep.demo.pojo.entity.Result;
import cn.dhnep.demo.pojo.entity.TbActivity;
import cn.dhnep.demo.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 邱文彬
 * @Date 2021/12/6 10:21
 * @Version 1.0
 */


@Service
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public Result insertActivity(String urlName, String activity,String pictureName,double targetWeight) {

        if(urlName == null){

            return new Result(0,"图片地址为空",null);
        }
        System.out.println("开始执行");
        int code = activityMapper.insertActivity(urlName,activity,pictureName,targetWeight);

        if(code > 0){
            return new Result(0,"操作成功",urlName);
        }
        return new Result(0,"操作失败",null);
    }

    @Override
    public Result getAll() {

        List<TbActivity> tbActivity = activityMapper.getAll();
        return new Result(0,"操作成功",tbActivity);
    }
}
